package com.cykj.user.controller;

import com.cykj.common.core.web.controller.BaseController;
import com.cykj.common.core.web.domain.AjaxResult;
import com.cykj.user.dto.UserDTO;
import com.cykj.user.service.IHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/history")
public class HistoryController extends BaseController {

    @Autowired
    private IHistoryService historyService;


    @PostMapping
    public AjaxResult addBrowseHistory(@RequestBody UserDTO dto) {
        return toAjax(historyService.addBrowseHistory(dto.getBusinessId(), dto.getCustomerId()));
    }

    // 获取用户浏览历史
    @GetMapping("/list")
    public AjaxResult getBrowseHistory(@RequestParam Long customerId) {
        return AjaxResult.success("查询成功", historyService.getBrowseHistory(customerId));
    }


    // 删除浏览记录
    @DeleteMapping("/{id}")
    public AjaxResult deleteBrowseHistory(@PathVariable Long id) {
        return toAjax(historyService.deleteBrowseHistory(id));
    }


}




